/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-06-19 10:59:59
 * @LastEditTime : 2023-06-19 16:56:18
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\DiyList\HomePage\Common.jsx
 * @Description  :
 */

// 环形进度条
export const RingProgressSetUp = (percent, theme, title) => ({
    height: 150,
    width: 150,
    autoFit: false,
    percent,
    innerRadius: 0.85,
    color: [`rgb(${theme})`, `rgba(${theme},.1)`],
    progressStyle: { lineCap: 'round' },
    statistic: {
        title: {
            offsetY: 10,
            style: {
                color: `rgb(${theme})`,
                fontSize: '30px',
                lineHeight: '30px',
                fontFamily: 'Bahnschrift',
                fontWeight: 'bold',
            },
            formatter: ({ percent }) => ` ${(percent * 100).toFixed(0)}%`,
        },
        content: {
            offsetY: 10,
            style: { color: `rgb(${theme})`, fontSize: '16px', lineHeight: '16px', fontFamily: 'PingFang' },
            formatter: () => title || '合格率',
        },
    },
})

// 单柱型统计图
export const ColumnDataSetUp = (data, theme, yField, size, unit) => {
    const { width, height } = size
    return {
        data,
        padding: [10, 0, 45, 40],
        width,
        height,
        maxColumnWidth: 14,
        color: `l(270) 0:rgba(${theme},0.1) 1:rgb(${theme})`,
        xField: 'type',
        yField,
        tooltip: { formatter: e => ({ name: e.type, value: e[yField] + unit }) },
        scrollbar: {
            type: 'horizontal',
            categorySize: 120,
            style: {
                thumbColor: `rgba(${theme},0.5)`,
                trackColor: `rgba(${theme},0.1)`,
                thumbHighlightColor: `rgba(${theme},0.9)`,
            },
        },
    }
}

// 多柱子统计
export const GroupingColumnSetUp = (data, theme, size) => {
    const { width, height } = size
    return {
        data,
        padding: [40, 16, 40, 40],
        width,
        height,
        isGroup: true,
        maxColumnWidth: 14,
        color: [`#177DDC`, '#49AA19', '#FAAD14', '#FF4D4F'],
        xField: 'type',
        yField: 'value',
        seriesField: 'title',
        legend: { layout: 'horizontal', position: 'top', itemName: { style: { fill: '#818894', fontSize: 15 } } },
        scrollbar: {
            type: 'horizontal',
            categorySize: 120,
            style: {
                thumbColor: `rgba(${theme},0.5)`,
                trackColor: `rgba(${theme},0.1)`,
                thumbHighlightColor: `rgba(${theme},0.9)`,
            },
        },
    }
}
